import {api} from './libs/api.js';
let _self;
export const index =  {
	data() {
		return {
			produtPar:[],
			params:{},
			orderItemId:0,
			optLock:false,
			tabItem:"1",
			optShow:false,
			popupShow:false,
			formData:{},
			product:{"pcategory":"PVC","roll_price":3.2,"roll_weight":1},
			icons:{"50":uni.upx2px(50),"60":uni.upx2px(60),"45":uni.upx2px(45),"40":uni.upx2px(40),"30":uni.upx2px(30)},
		}
	},
	
	mounted() {
		_self = this;
	},
	
	onLoad:function(option) {
		this.params=option;
		this.orderItemId=this.params["order_item_id"]?this.params["order_item_id"]:0;
		console.log(option);
	},
	/*onShow:function(option) {},
	onReady:function(option) {},*/
	methods: {
		initData: async function(){
			uni.showLoading({title: '加载中'});
			let formInfo={};
			this.product=await api.dataInfo(this.params);
			if(this.params["order_item_id"]){
				let orderItem=await api.orderItemInfo({id:this.params["order_item_id"]} );
				if(orderItem["data_json"]) formInfo=orderItem["data_json"];

				/*this.product["saler"]=orderItem["data_json"]["saler"];
				this.product["customer"]=orderItem["data_json"]["customer"];*/
			}else{
				//formInfo={"saler":this.member} ;
				
				//formInfo=this.$store.state.user.orderInfo;
				//formInfo=uni.getStorageSync('USER_PRE_DATA');
				let userToken =  uni.getStorageSync('USER_TOKEN');
				let userInfo = await api.getMember({"token":userToken});
				if(userInfo.data1){
					formInfo=userInfo.data1;
				}
				
				
				
			}
			
			if(this.params["code"]) formInfo["inventory_code"]=this.params["code"];
			
			this.formData=formInfo;

			this.produtPar=[];
			if(this.product){				
				for(let index in api.produtParMap){
					if(!this.product[index]) continue;
					this.produtPar.push({"name":api.produtParMap[index],"val":this.product[index]});
				}
			}
			uni.hideLoading();
		},
		
		selectTab:function(event){
			this.tabItem=event.currentTarget.dataset.id;
		},
		
		createOrder:function(){
			this.popupShow=true;
		},

		
		
	},
}